package crm.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import crm.tools.Constants;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;



/**
 * sys/** 路径下的权限拦截器
 * @author ThinkerCJB
 *
 */
public class SysInterceptor extends HandlerInterceptorAdapter{
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session = request.getSession();
		// 判断session中是否有登录用户
		if(null != session.getAttribute(Constants.USER_SESSION)){
			return true;
		}
		// 如果没有用户，跳转到401无权限页面。
		response.sendRedirect(request.getContextPath()+"/401.jsp");
		return false;
	}

}
